package cn.tedu.review;
/**本类用于复习多线程编辑实现方案2:implements runnable*/
public class TestRunnable1 {
    public static void main(String[] args) {
        TicketRunnable target = new TicketRunnable();
        Thread t1 = new Thread(target);
        Thread t2 = new Thread(target);
        Thread t3 = new Thread(target);
        Thread t4 = new Thread(target);
        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
class TicketRunnable implements Runnable{
    int tickets = 100;
    @Override
    public void run() {
        while (true){
            System.out.println(Thread.currentThread().getName()+"="+tickets--);//返回对当前正在执行的线程对象的引用,与名字
            if (tickets<=0)break;
        }
    }
}